package errmsg

const ( //go声明常量的关键词
	SUCCESS = 200
	ERROR   = 400

	//----------------------------------------------------------------
	//开始分块因为在model中有User,Article,Category三个处理模块
	//code=1000...用户模块错误

	ERROR_USERNAME_USED  = 1001
	ERROR_PASSWORD_WRONG = 1002
	ERROR_USER_NOT_EXIST = 1003
	ERROR_TOKEN_EXIST    = 1004
	ERROR_TOKEN_TIMEOUT  = 1005
	ERROR_TOKEN_WRONG    = 1006
	ERROR_TOKEN_FORMAT   = 1007
	ERROR_USER_NO_RIGHT  = 1008
	//code=2000...文章模块错误

	ERROR_ART_NOT_EXIST = 2001

	//code=3000...分类模块错误

	ERROR_CATENAME_USED  = 3001
	ERROR_CATE_NOT_EXIST = 3002
)

var codeMsg = map[int]string{ //声明一个字典int对于声明的常量string对应的信息
	SUCCESS:              "success",
	ERROR:                "fail",
	ERROR_USERNAME_USED:  "username already used",
	ERROR_PASSWORD_WRONG: "password wrong",
	ERROR_USER_NOT_EXIST: "user not exist",
	ERROR_TOKEN_EXIST:    "token already exist",
	ERROR_TOKEN_TIMEOUT:  "token timeout",
	ERROR_TOKEN_WRONG:    "token wrong",
	ERROR_TOKEN_FORMAT:   "token format error",
	ERROR_USER_NO_RIGHT:  "user no right",

	ERROR_ART_NOT_EXIST: "art not exist",

	ERROR_CATENAME_USED:  "category already used",
	ERROR_CATE_NOT_EXIST: "cate not exist",

	//code=1000...用户模块错误
	//code=2000...文章模块错误
	//code=3000...分类模块错误
}

func GetErrMsg(code int) string {
	return codeMsg[code]
}
